package com.fc.redis.excel_bean;

import com.fc.redis.entity.TbUser;
import com.fc.redis.util.ExportExcelBean;
import org.apache.poi.hssf.usermodel.HSSFRow;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @program: fc-redis->UserExcelBean
 * @description: 测试excel写出bean
 * @author: G_Y
 * @create: 2019-09-07 08:53
 **/
public class UserExcelBean extends ExportExcelBean<TbUser> {

    public UserExcelBean(@NotBlank String fileName, @NotBlank String sheetName, @NotNull String[] tableHeader, @NotEmpty List<TbUser> rows) {
        super(fileName, sheetName, tableHeader, rows);
    }

    @Override
    public void writeExportExcelRow(HSSFRow row, TbUser user) {
        // 手动实现 每一列 对应的 对象 属性值
        row.createCell(0).setCellValue(ifNull(user.getId()));
        row.createCell(1).setCellValue(ifNull(user.getName()));
        row.createCell(2).setCellValue(ifNull(user.getPhone()));
    }

}
